//
//  OCPreferencesViewController.m
//  League
//
//  Created by JackChen on 2018/2/20.
//  Copyright © 2018年 ciyuanjuzhen. All rights reserved.
//

#import "OCPreferencesViewController.h"
#import "SegmentCell.h"
#import "PreferencesRangeSliderCell.h"
#import "ProfileSelectCell.h"
#import "ProfileDoneCell.h"
#import "ProdileModel.h"
#import "ChoseCityViewController.h"
#import "PickerListViewController.h"
#import "WaitForAuditViewController.h"
#import "MyPerfrenceModel.h"
#import "RegisterSuccessView.h"

@interface OCPreferencesViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (strong, nonatomic) UITableView *tableView;
@property (strong, nonatomic) ProfileManager *manager;
@property (strong, nonatomic) NSMutableArray *cityList;

@end

@implementation OCPreferencesViewController
static NSString *const cellIdentity_segment = @"segmentCell";
static NSString *const cellIdentity_rangeSlider = @"rangeSlider";
static NSString *const cellIdentity_select = @"select";
static NSString *const cellIdentity_done = @"done";

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.tableView];
    self.title = [self.languageBundle localizedStringForKey:@"Preferences" value:nil table:@"hello"];
    
    self.cityList = [NSMutableArray array];
    self.manager = [ProfileManager shareManager];
    if (self.manager.preferEducationsArray == nil) {
        self.manager.preferEducationsArray = [NSMutableArray array];
    }
    if (self.manager.preferReligionsArray == nil) {
        self.manager.preferReligionsArray = [NSMutableArray array];
    }
    self.manager.agemin = 18;
    self.manager.agemax = 50;
    self.manager.heightmin = 140;
    self.manager.heightmax = 200;
    [self getCities];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.tableView reloadData];
}

- (void)nextAction:(UIButton *)sender {
    if (self.isRegister == NO) {
        NSDictionary *dic = [self getEditParameters];
        NSString *urlStr = [NSString stringWithFormat:@"%@%@",kFirstUrl,kEditPerfenrece];
        NSLog(@"urlStr:%@",urlStr);
        [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        [DataContrller PostRequestUrl:urlStr Param:dic requestSuccess:^(NSDictionary *backDic) {
            NSLog(@"backDic:%@",backDic);
            [MBProgressHUD hideHUDForView:self.view animated:YES];
            if ([backDic[@"returnCode"] integerValue] == 200) {
                [self.navigationController popViewControllerAnimated:YES];
            } else {
                [self showErrorsWithMessage:backDic];
            }
        } requestFail:^(NSString *backErrorStr) {
            NSLog(@"backErrorStr:%@",backErrorStr);
            [MBProgressHUD hideHUDForView:self.view animated:YES];
        }];
        return ;
    }
    
    NSDictionary *parameters = [self setParameters];
    NSString *urlStr = [NSString stringWithFormat:@"%@%@",kFirstUrl,kRegisterUrl];
    NSLog(@"urlStr:%@",urlStr);
    [DataContrller PostRequestUrl:urlStr Param:parameters requestSuccess:^(NSDictionary *backDic) {
        NSLog(@"backDic:%@",backDic);
        if ([backDic[@"returnCode"] integerValue] == 200) {
            self.manager = nil;
            NSString *string = [self.languageBundle localizedStringForKey:@"waitAuditTitle" value:nil table:@"hello"];
            RegisterSuccessView *success = [[RegisterSuccessView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) ErrorMessage:string];
            [[[UIApplication sharedApplication] keyWindow] addSubview:success];
            /*
            WaitForAuditViewController *waitVc = [[WaitForAuditViewController alloc] init];
            self.manager = nil;
            [self.navigationController pushViewController:waitVc animated:YES];
            */
            
        } else {
            [self showErrorsWithMessage:backDic];
        }
    } requestFail:^(NSString *backErrorStr) {
        NSLog(@"backErrorStr:%@",backErrorStr);
    }];
}

- (void)getCities {
    NSDictionary *dic = @{
                          @"parentid":@(0),
                          @"typename":@"LocationCity"
                          };
    NSString *urlStr = [NSString stringWithFormat:@"%@%@",kFirstUrl,kGetDictionary];
    NSLog(@"urlStr:%@",urlStr);
    [DataContrller PostRequestUrl:urlStr Param:dic requestSuccess:^(NSDictionary *backDic) {
        NSLog(@"backDic:%@",backDic);
        if ([backDic[@"returnCode"] integerValue] == 200) {
            for (NSDictionary *city in backDic[@"obj"]) {
                ProdileModel *model = [[ProdileModel alloc] initWithDictionary:city error:nil];
                if (model != nil) {
                    [self.cityList addObject:model];
                }
                if (self.cityList.count > 0) {
                    //第一个默认选中
                    ProdileModel *defaultmodel = self.cityList[0];
                    self.manager.preferLocation = defaultmodel._id;
                }
                
                if (self.isRegister == NO) {
                    [self getPerfenrece];
                }
            }
            [self.tableView reloadData];
        } else {
            
        }
    } requestFail:^(NSString *backErrorStr) {
        
        NSLog(@"backErrorStr:%@",backErrorStr);
        
    }];
}

- (void)getPerfenrece {
    NSDictionary *dic = @{
                          @"pk":[UserInfomation shareManager].pk
                          };
    NSString *urlStr = [NSString stringWithFormat:@"%@%@",kFirstUrl,kGetPerfenrece];
    NSLog(@"urlStr:%@",urlStr);
    [DataContrller PostRequestUrl:urlStr Param:dic requestSuccess:^(NSDictionary *backDic) {
        NSLog(@"backDic:%@",backDic);
        if ([backDic[@"returnCode"] integerValue] == 200) {
            MyPerfrenceModel *model = [[MyPerfrenceModel alloc] initWithDictionary:backDic[@"obj"] error:nil];
            self.manager.lookfor = model.sex;
            self.manager.agemin = model.agemin;
            self.manager.agemax = model.agemax;
            self.manager.heightmin = model.heightmin;
            self.manager.heightmax = model.heightmax;
            self.manager.preferLocation = model.location;
            if (self.manager.preferEducationsArray == nil) {
                self.manager.preferEducationsArray = [NSMutableArray array];
            }
            [self.manager.preferEducationsArray removeAllObjects];
            [self.manager.preferEducationsArray addObject:model.education];
            self.manager.preferEducation = model.educationStr;
            self.manager.preferReligionsArray = [NSMutableArray arrayWithArray:model.religions];
            
            [self.tableView reloadData];
        } else {
            
        }
    } requestFail:^(NSString *backErrorStr) {
        
    }];
}

- (NSDictionary *)getEditParameters {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setObject:[UserInfomation shareManager].pk forKey:@"pk"];
    [parameters setObject:@(self.manager.lookfor) forKey:@"lookfor"];
    [parameters setObject:@(self.manager.agemin) forKey:@"agemin"];
    [parameters setObject:@(self.manager.agemax) forKey:@"agemax"];
    [parameters setObject:@(self.manager.heightmin) forKey:@"heightmin"];
    [parameters setObject:@(self.manager.heightmax) forKey:@"heightmax"];
    if (self.manager.preferLocation != nil) {
        [parameters setObject:self.manager.preferLocation forKey:@"preferLocation"];
    }
    //look for 教育
    if (self.manager.preferEducationsArray.count != 0) {
        NSMutableString *preferEducationString = [NSMutableString string];
        for (int i=0; i<self.manager.preferEducationsArray.count; i++) {
            if (i == self.manager.preferEducationsArray.count - 1) {
                [preferEducationString appendString:[NSString stringWithFormat:@"%@", self.manager.preferEducationsArray[i]]];
            } else {
                [preferEducationString appendString:[NSString stringWithFormat:@"%@;", self.manager.preferEducationsArray[i]]];
            }
        }
        if (preferEducationString != nil) {
            [parameters setObject:preferEducationString forKey:@"preferEducation"];
        }
    }
    //look for 宗教
    if (self.manager.preferReligionsArray.count != 0) {
        NSMutableString *preferReligionsString = [NSMutableString string];
        for (int i=0; i<self.manager.preferReligionsArray.count; i++) {
            if (i == self.manager.preferReligionsArray.count - 1) {
                [preferReligionsString appendString:[NSString stringWithFormat:@"%@", self.manager.preferReligionsArray[i]]];
            } else {
                [preferReligionsString appendString:[NSString stringWithFormat:@"%@;", self.manager.preferReligionsArray[i]]];
            }
        }
        if (preferReligionsString != nil) {
            [parameters setObject:preferReligionsString forKey:@"preferReligion"];
        }
    }
    NSString *lan = [InternationalControl userLanguage];
    if([lan isEqualToString:@"en"]){//判断当前的语言，进行改变
        [parameters setObject:@(1) forKey:@"systemLanguage"];
    } else {
        [parameters setObject:@(0) forKey:@"systemLanguage"];
    }
    return parameters;
}

- (void)choseCity:(UIButton *)sender {
    if (sender.tag - 300 == 3) {
        ChoseCityViewController *vc = [self  initializeStoryboardViewControllerWithStoryboardID:@"LoginRegister" viewcontroller:@"ChoseCityViewController"];
        vc.dataSource = self.cityList;
        vc.selectBlock = ^{
            [self.tableView reloadData];
        };
        vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
        vc.view.backgroundColor = [UIColor colorWithWhite:.0f alpha:0.6f];
        [self.navigationController presentViewController:vc animated:NO completion:nil];
    } else if (sender.tag - 300 == 4) {
        PickerListViewController *pickerVc = [[PickerListViewController alloc] init];
        pickerVc.isProfile = NO;
        pickerVc.index = sender.tag;
        pickerVc.type = PreferEducation;
        [self presentViewController:pickerVc animated:YES completion:nil];
    } else {
        PickerListViewController *pickerVc = [[PickerListViewController alloc] init];
        pickerVc.isProfile = NO;
        pickerVc.index = sender.tag;
        pickerVc.type = Religion;
        [self presentViewController:pickerVc animated:YES completion:nil];
    }
}

- (NSDictionary *)setParameters {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    if (self.manager.phone != nil) {
        [parameters setObject:self.manager.phone forKey:@"phone"];
    }
    [parameters setObject:self.manager.areaCode forKey:@"areaCode"];
    [parameters setObject:@(self.manager.sex) forKey:@"sex"];
    if (self.manager.username != nil) {
        [parameters setObject:self.manager.username forKey:@"username"];
        [parameters setObject:self.manager.username forKey:@"realname"];
    }
    if (self.manager.password != nil) {
        [parameters setObject:self.manager.password forKey:@"password"];
    }
    if (self.manager.email != nil) {
        [parameters setObject:self.manager.email forKey:@"email"];
    }
    [parameters setObject:@(self.manager.age) forKey:@"age"];
    //照片
    if (self.manager.photoIds.count != 0) {
        NSMutableString *photoString = [NSMutableString string];
        for (int i=0; i<self.manager.photoIds.count; i++) {
            if (i == self.manager.photoIds.count - 1) {
                [photoString appendString:[NSString stringWithFormat:@"%@", self.manager.photoIds[i]]];
            } else {
                [photoString appendString:[NSString stringWithFormat:@"%@;", self.manager.photoIds[i]]];
            }
        }
        if (photoString != nil) {
            [parameters setObject:photoString forKey:@"photoIds"];
        }
    }
    if (self.manager.aboutme != nil) {
        [parameters setObject:self.manager.aboutme forKey:@"aboutme"];
    }
    [parameters setObject:@(self.manager.sex) forKey:@"sex"];
    [parameters setObject:@(self.manager.height) forKey:@"height"];
    [parameters setObject:@(self.manager.single) forKey:@"single"];
    //宗教
    if (self.manager.religionsArray.count != 0) {
        NSMutableString *religionsString = [NSMutableString string];
        for (int i=0; i<self.manager.religionsArray.count; i++) {
            if (i == self.manager.religionsArray.count - 1) {
                [religionsString appendString:[NSString stringWithFormat:@"%@", self.manager.religionsArray[i]]];
            } else {
                [religionsString appendString:[NSString stringWithFormat:@"%@;", self.manager.religionsArray[i]]];
            }
        }
        if (religionsString != nil) {
            [parameters setObject:religionsString forKey:@"religion"];
        }
    }
    //职业
    if (self.manager.professionsArray.count != 0) {
        NSMutableString *professionsString = [NSMutableString string];
        for (int i=0; i<self.manager.professionsArray.count; i++) {
            if (i == self.manager.professionsArray.count - 1) {
                [professionsString appendString:[NSString stringWithFormat:@"%@", self.manager.professionsArray[i]]];
            } else {
                [professionsString appendString:[NSString stringWithFormat:@"%@;", self.manager.professionsArray[i]]];
            }
        }
        if (professionsString != nil) {
            [parameters setObject:professionsString forKey:@"professions"];
        }
    }
    //教育
    if (self.manager.educationsArray.count != 0) {
        NSMutableString *educationsString = [NSMutableString string];
        for (int i=0; i<self.manager.educationsArray.count; i++) {
            if (i == self.manager.educationsArray.count - 1) {
                [educationsString appendString:[NSString stringWithFormat:@"%@", self.manager.educationsArray[i]]];
            } else {
                [educationsString appendString:[NSString stringWithFormat:@"%@;", self.manager.educationsArray[i]]];
            }
        }
        if (educationsString != nil) {
            [parameters setObject:educationsString forKey:@"educations"];
        }
    }
    //兴趣
    if (self.manager.interestsArray.count != 0) {
        NSMutableString *interestsString = [NSMutableString string];
        for (int i=0; i<self.manager.interestsArray.count; i++) {
            if (i == self.manager.interestsArray.count - 1) {
                [interestsString appendString:[NSString stringWithFormat:@"%@", self.manager.interestsArray[i]]];
            } else {
                [interestsString appendString:[NSString stringWithFormat:@"%@;", self.manager.interestsArray[i]]];
            }
        }
        if (interestsString != nil) {
            [parameters setObject:interestsString forKey:@"interests"];
        }
    }
    [parameters setObject:@(self.manager.lookfor) forKey:@"lookfor"];
    [parameters setObject:@(self.manager.agemin) forKey:@"agemin"];
    [parameters setObject:@(self.manager.agemax) forKey:@"agemax"];
    [parameters setObject:@(self.manager.heightmin) forKey:@"heightmin"];
    [parameters setObject:@(self.manager.heightmax) forKey:@"heightmax"];
    if (self.manager.location != nil) {
        [parameters setObject:self.manager.location forKey:@"location"];
    }
    if (self.manager.preferLocation != nil) {
        [parameters setObject:self.manager.preferLocation forKey:@"preferLocation"];
    }
    //look for 教育
    if (self.manager.preferEducationsArray.count != 0) {
        NSMutableString *preferEducationString = [NSMutableString string];
        for (int i=0; i<self.manager.preferEducationsArray.count; i++) {
            if (i == self.manager.preferEducationsArray.count - 1) {
                [preferEducationString appendString:[NSString stringWithFormat:@"%@", self.manager.preferEducationsArray[i]]];
            } else {
                [preferEducationString appendString:[NSString stringWithFormat:@"%@;", self.manager.preferEducationsArray[i]]];
            }
        }
        if (preferEducationString != nil) {
            [parameters setObject:preferEducationString forKey:@"preferEducation"];
        }
    }
    //look for 宗教
    if (self.manager.preferReligionsArray.count != 0) {
        NSMutableString *preferReligionsString = [NSMutableString string];
        for (int i=0; i<self.manager.preferReligionsArray.count; i++) {
            if (i == self.manager.preferReligionsArray.count - 1) {
                [preferReligionsString appendString:[NSString stringWithFormat:@"%@", self.manager.preferReligionsArray[i]]];
            } else {
                [preferReligionsString appendString:[NSString stringWithFormat:@"%@;", self.manager.preferReligionsArray[i]]];
            }
        }
        if (preferReligionsString != nil) {
            [parameters setObject:preferReligionsString forKey:@"preferReligion"];
        }
    }
    NSString *lan = [InternationalControl userLanguage];
    if([lan isEqualToString:@"en"]){//判断当前的语言，进行改变
        [parameters setObject:@(1) forKey:@"systemLanguage"];
    } else {
        [parameters setObject:@(0) forKey:@"systemLanguage"];
    }
    return parameters;
}

#pragma mark -- tableView delegate and dataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 7;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSBundle *bundle = self.languageBundle;
    if (indexPath.row == 0) {
        SegmentCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentity_segment];
        if (cell == nil) {
            cell = [[SegmentCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentity_segment];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.state = ProferenceSexState;
        NSString *titleString = [bundle localizedStringForKey:@"Sex" value:nil table:@"hello"];
        NSArray *array = [NSArray arrayWithObjects:[bundle localizedStringForKey:@"Women" value:nil table:@"hello"],[bundle localizedStringForKey:@"Men" value:nil table:@"hello"],[bundle localizedStringForKey:@"Both" value:nil table:@"hello"], nil];
        [cell bindViewWithTitle:titleString segmentState:array];
        [cell.stateSegment setSelectedSegmentIndex:self.manager.lookfor];
        return cell;
    }
    if (indexPath.row == 1 || indexPath.row == 2) {
        PreferencesRangeSliderCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentity_rangeSlider];
        if (cell == nil) {
            cell = [[PreferencesRangeSliderCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentity_rangeSlider];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        NSString *titleString;
        if (indexPath.row == 1) {
            titleString = [bundle localizedStringForKey:@"Age" value:nil table:@"hello"];
            cell.min = 1;
            cell.max = 100;
            if (self.manager.agemin == 0 || self.manager.agemax == 0) {
                cell.selectmin = 16;
                cell.selectmax = 40;
            } else {
                cell.selectmin = self.manager.agemin;
                cell.selectmax = self.manager.agemax;
            }
            [cell setSelectNum];
        }
        if (indexPath.row == 2) {
            titleString = [bundle localizedStringForKey:@"Height" value:nil table:@"hello"];
            cell.min = 100;
            cell.max = 220;
            if (self.manager.heightmin == 0 || self.manager.heightmax == 0) {
                cell.selectmin = 140;
                cell.selectmax = 200;
            } else {
                cell.selectmin = self.manager.heightmin;
                cell.selectmax = self.manager.heightmax;
            }
            [cell setSelectNum];
        }
        cell.titleLabel.text = titleString;
        
        return cell;
    }
    if (indexPath.row == 3 || indexPath.row == 4 || indexPath.row == 5) {
        ProfileSelectCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentity_select];
        if (cell == nil) {
            cell = [[ProfileSelectCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentity_select];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        NSString *titleString;
        if (indexPath.row == 3) {
            titleString = [bundle localizedStringForKey:@"Distance" value:nil table:@"hello"];
            if (self.isRegister == YES && self.cityList.count > 0) {
                for (int i = 0; i<self.cityList.count; i++) {
                    ProdileModel *model = self.cityList[i];
                    if ([model._id isEqualToString:[ProfileManager shareManager].preferLocation]) {
                        NSString *lan = [InternationalControl userLanguage];
                        if([lan isEqualToString:@"en"]){//判断当前的语言，进行改变
                            [cell.locationButton setTitle:model.categoryDesc forState:UIControlStateNormal];
                        } else {
                            [cell.locationButton setTitle:model.categoryName forState:UIControlStateNormal];
                        }
                    }
                }
            }
        }
        if (indexPath.row == 4) {
            titleString = [bundle localizedStringForKey:@"Education" value:nil table:@"hello"];
            if (self.manager.preferEducationsArray.count == 0) {
                [cell.locationButton setTitle:[bundle localizedStringForKey:@"NoPreference" value:nil table:@"hello"] forState:UIControlStateNormal];
            } else {
                [cell.locationButton setTitle:[NSString stringWithFormat:@"%@", self.manager.preferEducation] forState:UIControlStateNormal];
            }
        }
        if (indexPath.row == 5) {
            titleString = [bundle localizedStringForKey:@"Religion" value:nil table:@"hello"];
            if (self.manager.preferReligionsArray.count == 0) {
                [cell.locationButton setTitle:[bundle localizedStringForKey:@"NoPreference" value:nil table:@"hello"] forState:UIControlStateNormal];
            } else {
                [cell.locationButton setTitle:[NSString stringWithFormat:@"%ld religions selected", self.manager.preferReligionsArray.count] forState:UIControlStateNormal];
            }
        }
        cell.titleLabel.text = titleString;
        cell.locationButton.tag = 300 + indexPath.row;
        [cell.locationButton addTarget:self action:@selector(choseCity:) forControlEvents:UIControlEventTouchUpInside];
        
        return cell;
    }
    if (indexPath.row == 6) {
        ProfileDoneCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentity_done];
        if (cell == nil) {
            cell = [[ProfileDoneCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentity_done];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell.doneButton addTarget:self action:@selector(nextAction:) forControlEvents:UIControlEventTouchUpInside];
        if (self.isRegister == NO) {
            [cell.doneButton setTitle:[bundle localizedStringForKey:@"over" value:nil table:@"hello"] forState:UIControlStateNormal];
        } else {
            [cell.doneButton setTitle:[bundle localizedStringForKey:@"Next" value:nil table:@"hello"] forState:UIControlStateNormal];
        }
        return cell;
    }
    
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        return 50;
    }
    if (indexPath.row == 1 || indexPath.row == 2) {
        return 80;
    }
    if (indexPath.row == 3 || indexPath.row == 4 || indexPath.row == 5) {
        return 70;
    }
    if (indexPath.row == 6) {
        return 64;
    }
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
    view.backgroundColor = [UIColor whiteColor];
    return view;
}

#pragma mark setter and getter
- (UITableView *)tableView {
    if (_tableView) {
        return _tableView;
    }
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.estimatedRowHeight = 0;
    _tableView.estimatedSectionHeaderHeight = 0;
    _tableView.estimatedSectionFooterHeight = 0;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    //注册cell
    UINib *nib_segment = [UINib nibWithNibName:@"SegmentCell" bundle:nil];
    [_tableView registerNib:nib_segment forCellReuseIdentifier:cellIdentity_segment];
    UINib *nib_slider = [UINib nibWithNibName:@"PreferencesRangeSliderCell" bundle:nil];
    [_tableView registerNib:nib_slider forCellReuseIdentifier:cellIdentity_rangeSlider];
    UINib *nib_select = [UINib nibWithNibName:@"ProfileSelectCell" bundle:nil];
    [_tableView registerNib:nib_select forCellReuseIdentifier:cellIdentity_select];
    UINib *nib_done = [UINib nibWithNibName:@"ProfileDoneCell" bundle:nil];
    [_tableView registerNib:nib_done forCellReuseIdentifier:cellIdentity_done];
    return _tableView;
}

@end
